package cn.byapps.chensheng.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import cn.byapps.chensheng.entity.WxMaterial;

/**
 * @author iva0512@gmail.com
 */
public interface WxMaterialDao {
    @Results(id = "item", value = { @Result(property = "mediaId", column = "media_id", id = true),
            @Result(property = "appId", column = "app_id"), @Result(property = "updateTime", column = "update_time") })
    @Select("select * from wx_material")
    List<WxMaterial> findAll();

    @ResultMap("item")
    @Select("select * from wx_material")
    List<WxMaterial> findByPage(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);

    @ResultMap("item")
    @Select("select * from wx_material where app_id = #{appId}")
    List<WxMaterial> findbyAppId(String appId);

    @ResultMap("item")
    @Select("select * from wx_material where app_id = #{appId} order by update_time desc")
	List<WxMaterial> findPageByAppid(@Param("appId")String appId, @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);

    @Select("select count(*) from  wx_material where app_id = #{appId}")
	Integer countByAppId(String appid);
}